package guoanmaker.operator.business.repository;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import guoanmaker.operator.business.model.ResidueCount;

public interface OperatorResidueCountRepository extends JpaRepository<ResidueCount, String>, JpaSpecificationExecutor<ResidueCount>{
	@Modifying
	@Transactional
	@Query("update ResidueCount t set t.residueCount = t.residueCount - 1, t.lastQueryDate = NOW() where t.id = '2c90a8675fbe38bb015fc4082e1a0001' ")
	void patentSearchMinusOne();
	@Modifying
	@Transactional
	@Query("update ResidueCount t set t.residueCount = t.residueCount - 1, t.lastQueryDate = NOW() where t.id = '2c90a8675fbe38bb015fc4082e1a0002' ")
	void patentInfoSearchMinusOne();
	@Query("select t from ResidueCount t  where t.id = '2c90a8675fbe38bb015fc4082e1a0001' ")
	ResidueCount getPatentSearch();
	@Query("select t from ResidueCount t  where t.id = '2c90a8675fbe38bb015fc4082e1a0002' ")
	ResidueCount getPatentSearchInfo();
	
	@Modifying
	@Transactional
	@Query("update ResidueCount t set t.residueCount = t.residueCount - 1, t.lastQueryDate = NOW() where t.id = '2c90a8675fbe38bb015fc4082e1a0003' ")
	void trademarkSearchMinusOne();
	@Modifying
	@Transactional
	@Query("update ResidueCount t set t.residueCount = ?1, t.lastQueryDate = NOW() where t.id = '2c90a8675fbe38bb015fc4082e1a0003' ")
	void trademarkSearchMinusOne(Integer count);
	@Modifying
	@Transactional
	@Query("update ResidueCount t set t.residueCount = t.residueCount - 1, t.lastQueryDate = NOW() where t.id = '2c90a8675fbe38bb015fc4082e1a0004' ")
	void trademarkInfoSearchMinusOne();
	@Modifying
	@Transactional
	@Query("update ResidueCount t set t.residueCount = ?1, t.lastQueryDate = NOW() where t.id = '2c90a8675fbe38bb015fc4082e1a0004' ")
	void trademarkInfoSearchMinusOne(Integer count);
	@Query("select t from ResidueCount t  where t.id = '2c90a8675fbe38bb015fc4082e1a0003' ")
	ResidueCount getTrademarkSearch();
	@Query("select t from ResidueCount t  where t.id = '2c90a8675fbe38bb015fc4082e1a0004' ")
	ResidueCount getTrademarkSearchInfo();
	
}
